home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8222 < prev    next >
Encoding:
Text File  |  1996-08-05  |  3.5 KB  |  110 lines

  1. Path: ix.netcom.com!netnews
  2. From: judgemi@ix.netcom.com (Michael Judge)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Visual C++ OLE/ODBC 16bit GPF
  5. Date: 15 Feb 1996 21:09:01 GMT
  6. Organization: TSI
  7. Message-ID: <4g07dd$o6c@reader2.ix.netcom.com>
  8. NNTP-Posting-Host: ix-bst-ma1-03.ix.netcom.com
  9. Mime-Version: 1.0
  10. Content-Type: Text/Plain; charset=US-ASCII
  11. X-NETCOM-Date: Thu Feb 15  1:09:01 PM PST 1996
  12. X-Newsreader: WinVN 0.99.7
  13.  
  14. Well I have called Microsoft and they have confirmed that there is a bug when 
  15. using Visual C++1.5x with OLE and ODBC.  I recreated it with the steps st the 
  16. end of this article.  The problem was with new ODBC drivers releasing 
  17. OLE2DISP.DLL from memory when a referenced should have still existed from the 
  18. OLE application.  The fix is to 
  19. 1) Add before (AfxOleInit()) in InitInstance
  20.     myOle2DispInstance=LoadLibrary("OLE2DISP");
  21. 2) Add to ExitInstance
  22.     FreeLibrary(myOle2DispInstance);
  23.  
  24. here is the following steps to recreate the problem. 
  25.  
  26. ----------------------------------------------------
  27. Re: message num  (169116)
  28.  
  29. This is for OLE/ODBC/Microsoft Visual C++ Gurus.
  30.  
  31. environment: Windows 3.X, ODBC DLLs ver 2.1
  32.  
  33. O.k. here is the problem then I will describe how to reproduce it. (takes 5 
  34. minutes to reproduce)
  35. When executing a SQL statement twice on a microsoft ODBC datasource, I recieve 
  36. a GP fault in COMPOBJ.DLL.
  37. This ONLY happens when ODBC drivers version 2.1 have been installed. So any 
  38. new machine, or old one with new
  39. software will reproduce this.  
  40.  
  41. If I replace OLE2DISP.DLL ver 2.1 with OLE2DISP.DLL ver 2.0 this problem 
  42. doesnt occur. (of course there are other side affects
  43. that make this a poor solution.)
  44.  
  45. here is the kicker! This only happens when I have a 'WHERE' clause in the 
  46. statement. and ONLY in RELEASE!
  47.  
  48. how to reproduce.                              
  49.  
  50. 1: AppWizard new project.
  51.     a. OLE options. (container)
  52.     b. shut off all check boxes under options. (simplifies things)
  53.     c. database support, include header files only
  54.     d. classes: change your view class to a formview class.
  55.     e. let it create all its files
  56. 2. AppStudio.
  57.     a. Add a button to your formview
  58.     b. class wizard: add a message map for bn_clicked
  59.     c. choose edit code
  60. 3. CMyFormView::OnButton1() should look like this (also add derivation of 
  61. CRecordset)
  62.  
  63. class CMyRecordSet: public CRecordset
  64. {
  65. public:
  66.     CMyRecordSet(CDatabase *t_ptr);
  67.     virtual CString GetDefaultSQL(){return CString("");}
  68.     virtual void DoFieldExchange(CFieldExchange* pFX){}
  69. };
  70. CMyRecordSet::CMyRecordSet(CDatabase *t_ptr)
  71. :CRecordset(t_ptr)
  72. {
  73. }
  74.  
  75. void CMyFormView::OnButton1()
  76. {
  77.     CDatabase t_pdatabase;
  78.     t_pdatabase.Open(NULL); 
  79.     CMyRecordSet t_set(&t_pdatabase);
  80.     t_set.Open();
  81.     CString t_sqlstatement("SELECT PHYSICIAN from EPD00045 where 
  82. physician='CHAMBERS'");
  83.     ::SQLExecDirect(t_set.m_hstmt,
  84.                  (UCHAR FAR*)t_sqlstatement.GetBuffer(0), SQL_NTS);
  85.     t_set.Close();
  86.     t_pdatabase.Close();
  87. }
  88.  
  89. 4. change t_sqlstatement to be whatever makes sense to your database you are 
  90. going after
  91. 5. build for release and execute.
  92. 6. click on button
  93. 7. choose a datasource that uses ODBCJT16.DLL (I have tried foxprow, access 
  94. and paradox datasources)
  95.     note: make sure your SQL makes sense
  96. 8. let it process call then click on button again.
  97.  
  98. Thats it.  
  99. Oh yes, after this happens, it wont blow up again until you leave windows and 
  100. return. 
  101. I have a VB test app that works fine with it.
  102. In debug it works
  103. replace OLE2DISP.DLL v2.1 with v2.0 it works
  104. if not an ole container it works
  105.  
  106. Email as well as post please.
  107. Email: judgemi@ix.netx.com
  108. ---------------------------------------------------------------------
  109.  
  110.